/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ie.tcd.cs.railtickets.server.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Wenbo Sun
 */

@Entity
@Table(name = "time_table")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
name="table_type", discriminatorType=DiscriminatorType.STRING
)
@DiscriminatorValue("TIME")
public class TimeTable implements Serializable {

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "time_id")
    private long id;

    @Temporal(TemporalType.TIME)
    @Column(name = "start_time")
    private Date startTime;

    @Column(name = "travel_period")
    private double travelPeriod;

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "travelTime")
    private Set<SeatState> seatStates;

    public TimeTable() {
    }

    public TimeTable(long id) {
        this.id = id;
    }

    public TimeTable(Date startTime, double travelPeriod) {
        this.startTime = startTime;
        this.travelPeriod = travelPeriod;
    }


    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public double getTravelPeriod() {
        return travelPeriod;
    }

    public void setTravelPeriod(double travelPeriod) {
        this.travelPeriod = travelPeriod;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Set<SeatState> getSeatStates() {
        return seatStates;
    }

    public void setSeatStates(Set<SeatState> seatStates) {
        this.seatStates = seatStates;
    }


}
